/**
 * May 12, 2014 10:19:47 AM
 */
package elitech.vietnam.copyweatherfashion.dialog;

import elitech.vietnam.copyweatherfashion.R;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

/**
 * @author Cong
 *
 */
public class ProgressDialogFragment extends DialogFragment {

	TextView mTextTitle, mTextMess;
	String mTitle, mMessage;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mMessage = getArguments().getString("MESSAGE");
		mTitle = getArguments().getString("TITLE");
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.progressdialog, container, false);
		
		mTextTitle = (TextView) view.findViewById(R.id.prg_texttitle);
		mTextMess = (TextView) view.findViewById(R.id.prg_textmess);
		
		mTextTitle.setText(mTitle);
		mTextMess.setText(mMessage);
		return view;
	}
	
	public void show(FragmentManager manager) {
		super.show(manager, getClass().getSimpleName());
	}
	
	/**
	 * @deprecated: Use {@link #show(FragmentManager)} instead
	 */
	@Deprecated
	@Override
	public void show(FragmentManager manager, String tag) {
		super.show(manager, tag);
	}
	
	public static class Builder {
		String mTitle, mMessage;
		
		public Builder setTitle(String title) {
			mTitle = title;
			return this;
		}
		
		public Builder setMessage(String message) {
			mMessage = message;
			return this;
		}
		
		public ProgressDialogFragment build() {
			ProgressDialogFragment fragment = new ProgressDialogFragment();
			Bundle bundle = new Bundle();
			bundle.putString("TITLE", mTitle);
			bundle.putString("MESSAGE", mMessage);
			fragment.setArguments(bundle);
			fragment.setStyle(STYLE_NO_TITLE, R.style.Dialog);
			fragment.setCancelable(false);
			return fragment;
		}
	}
}
